import { axiosUtil } from './axiosUtil.js'
import apiConfig from './apiConfig.js'
import { local } from '@/utils/jcore/storage'
const userInfo = local.get('userInfo')

export default class authority {
  static sysOverallInfo = userInfo || {}
  static bsCommodityApi = {
    //商品列表
    getprocessPage(data, callback) {
      let url = apiConfig.API.bsCommodityApi.getsysGroupPage
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //商品列表
    getAllList(data, callback) {
      let url = apiConfig.API.bsCommodityApi.getAllList
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //获取列表
    getByUserInfo(data, callback) {
      let url = apiConfig.API.bsCommodityApi.getByUserInfo
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //新增
    savesysGroupPage(data, callback) {
      let url = apiConfig.API.bsCommodityApi.savesysGroupPage
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //详情
    GroupByIdsys(data, callback) {
      let url = apiConfig.API.bsCommodityApi.GroupByIdsys
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //编辑
    updatesysGroupPage(data, callback) {
      let url = apiConfig.API.bsCommodityApi.updatesysGroupPage
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    //删除
    delete(data, callback) {
      let url = apiConfig.API.bsCommodityApi.delete
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    }
  }
  //招聘信息
  static bsRecruitmentApi = {
    getpage(data, callback) {
      let url = apiConfig.API.bsRecruitmentApi.getpage
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    delete(data, callback) {
      let url = apiConfig.API.bsRecruitmentApi.delete
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    getById(data, callback) {
      let url = apiConfig.API.bsRecruitmentApi.getById
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    save(data, callback) {
      let url = apiConfig.API.bsRecruitmentApi.save
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    update(data, callback) {
      let url = apiConfig.API.bsRecruitmentApi.update
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    }
  }
  //建筑咨询
  static architectureApi = {
    getpage(data, callback) {
      let url = apiConfig.API.bsConsultancyApi.getpage
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    delete(data, callback) {
      let url = apiConfig.API.bsConsultancyApi.delete
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    getById(data, callback) {
      let url = apiConfig.API.bsConsultancyApi.getById
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    save(data, callback) {
      let url = apiConfig.API.bsConsultancyApi.save
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    update(data, callback) {
      let url = apiConfig.API.bsConsultancyApi.update
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    }
  }
  //字典管理
  static dictApi = {
    addition(data, callback) {
      let url = apiConfig.API.dictApi.addition
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    delete(data, callback) {
      let url = apiConfig.API.dictApi.delete
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    getById(data, callback) {
      let url = apiConfig.API.dictApi.getById
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    getDictory(data, callback) {
      let url = apiConfig.API.dictApi.getDictory
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    getList(data, callback) {
      let url = apiConfig.API.dictApi.getList
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    },
    update(data, callback) {
      let url = apiConfig.API.dictApi.update
      axiosUtil.postJson(url, data, function (res) {
        callback(res)
      })
    }
  }
  // 菜单对应权限接口以及数据
  static MenuPort = {
    getMenuTree(data, callback) {
      //获取菜单数据
      let url = apiConfig.API.sysMenuApi.getSysMenuTreeOrBySysDutyId
      // let url ='abc'
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    saveAddMenu(data, callback) {
      //新建菜单
      let url = apiConfig.API.sysMenuApi.addMenuListUrl
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getSysMenuByid(data, callback) {
      //获取菜单详情
      // /sysMenuApi/getById
      let url = apiConfig.API.sysMenuApi.getbyidMenuListUrl
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    deleteMenuByid(data, callback) {
      //删除菜单
      let url = apiConfig.API.sysMenuApi.deleteMenuListUrl
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    updateMenu(data, callback) {
      //编辑菜单
      data = { ...data, sysOverallInfo: authority.sysOverallInfo }
      let forData = data
      let url = apiConfig.API.sysMenuApi.updateMenuListUrl
      axiosUtil.postUpdateJson(url, forData, function (res) {
        callback(res)
      })
    },
    rolesByidgetMenuTree(data, callback) {
      //根据角色获取菜单
      let url = apiConfig.API.sysMenuApi.getSysMenuTreeBySysDutyId
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    }
  }
  // 角色对应权限接口以及数据
  static RolesPort = {
    getRolelist(data, callback) {
      //获取角色分页
      let url = apiConfig.API.getRolelist.getRoleListPageUrl
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getAllSysRoles(data, callback) {
      //获取角色分页
      let url = apiConfig.API.getRolelist.getAllSysRoles
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getRoleListUrl(data, callback) {
      //获取当前岗位角色列表
      // let sysOverallInfo = JSON.parse(JSON.stringify(authority.sysOverallInfo))
      // sysOverallInfo.overallOrganizeId = data
      let url = apiConfig.API.getRolelist.getRoleListUrl
      axiosUtil.postJson(url, { sysOverallInfo: data }, function (res) {
        callback(res)
      })
    },
    getOperatorRoleListUrl(data, callback) {
      //获取当前操作人岗位角色列表
      let url = apiConfig.API.getRolelist.getRoleListUrl
      axiosUtil.postJson(url, { sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getRolesByid(data, callback) {
      let url = apiConfig.API.getRolelist.updateRoleListPageUrl
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    updateRoles(data, callback) {
      let url = apiConfig.API.getRolelist.updatesRoleListPageUrl
      axiosUtil.postUpdateJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    AddRoles(data, callback) {
      let url = apiConfig.API.getRolelist.addRoleListUrl
      axiosUtil.postAddJson(
        url,
        {
          ...data,
          sysOverallInfo: authority.sysOverallInfo
        },
        function (res) {
          callback(res)
        }
      )
    },
    DleteRoles(data, callback) {
      let url = apiConfig.API.getRolelist.delRoleListPageUrl
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    }
  }

  // 机构对应权限接口以及数据
  static OrganizationPort = {
    //获取组织机构树接口
    getOrganizationList(data, callback) {
      let url = apiConfig.API.sysOrganizeApi.getListUrl
      // let url = 'abc';
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    saveOrganization(data, callback) {
      //新增机构
      let url = apiConfig.API.sysOrganizeApi.savetreeUrl
      axiosUtil.postAddJson(url, { ...data, creator: authority.sysOverallInfo.overallUserID }, function (res) {
        callback(res)
      })
    },
    updateOrganization(data, callback) {
      //编辑机构
      let url = apiConfig.API.sysOrganizeApi.updateUrl
      axiosUtil.postUpdateJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    deleteOrganization(data, callback) {
      //删除机构
      let url = apiConfig.API.sysOrganizeApi.deletetreeUrl
      axiosUtil.postUpdateJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getByid(data, callback) {
      //获取机构详情
      let url = apiConfig.API.sysOrganizeApi.insertUrl
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    }
  }

  // 用户对应权限接口以及数据
  static UserPort = {
    saveUser(data, callback) {
      //新增用户
      let url = apiConfig.API.sysUserApi.addUserApi
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    // 获取所有用户
    page(data, callback) {
      //
      let url = apiConfig.API.sysUserApi.getUserFullInfoByDutyIdAndOrganize
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    deleteUser(data, callback) {
      //删除用户
      let url = apiConfig.API.sysUserApi.deletedUser
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getbyidUser(data, callback) {
      //获取用户详情
      let url = apiConfig.API.sysUserApi.getbyidUser
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    updateUser(data, callback) {
      //编辑用户
      let url = apiConfig.API.sysUserApi.updatedUser
      axiosUtil.postUpdateJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getUserSwitChoverUser(data, callback) {
      //超级管理员切换普通用户接口
      let url = apiConfig.API.sysUserApi.getUserSwitChoverUser
      axiosUtil.postJson(url, { sysOverallInfo: data }, function (res) {
        callback(res)
      })
    },

    alterEnableStatus(data, callback) {
      //启用停用
      let url = apiConfig.API.sysUserApi.alterEnableStatus
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    alterDeleteFlag(data, callback) {
      //注销
      let url = apiConfig.API.sysUserApi.alterDeleteFlag
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    }
  }
  // 供应商接口以及数据
  static bsSupplierApi = {
    saveUser(data, callback) {
      //新增供应商
      let url = apiConfig.API.bsSupplierApi.save
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    // 获取所有供应商
    page(data, callback) {
      //
      let url = apiConfig.API.bsSupplierApi.page
      axiosUtil.postAddJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    deleteUser(data, callback) {
      //删除供应商
      let url = apiConfig.API.bsSupplierApi.delete
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getbyidUser(data, callback) {
      //获取供应商详情
      let url = apiConfig.API.bsSupplierApi.getById
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    getSpApi(data, callback) {
      //获取绑定商品
      let url = apiConfig.API.bsSupplierApi.getBsSupplierCommodity
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    },
    boundBsSupplierCommodity(data, callback) {
      //获取绑定商品
      let url = apiConfig.API.bsSupplierApi.boundBsSupplierCommodity
      axiosUtil.postJson(url, { ...data, sysOverallInfo: authority.sysOverallInfo }, function (res) {
        callback(res)
      })
    }
  }
  // 卡片接口信息
  static bsCardImageApi = {
    //新增卡片
    savebsCardImageApi(data, callback) {
      let url = apiConfig.API.bsCardImageApi.save
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //编辑卡片
    updatebsCardImageApi(data, callback) {
      let url = apiConfig.API.bsCardImageApi.update
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片分页
    pagebsCardImageApi(data, callback) {
      let url = apiConfig.API.bsCardImageApi.page
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片详情
    getByIdbsCardImageApi(data, callback) {
      let url = apiConfig.API.bsCardImageApi.getById
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片删除
    deletebsCardImageApi(data, callback) {
      let url = apiConfig.API.bsCardImageApi.delete
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    }
  }
  // 招标信息
  static bsProBiddingApi = {
    //新增卡片
    save(data, callback) {
      let url = apiConfig.API.bsProBiddingApi.save
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //编辑卡片
    update(data, callback) {
      let url = apiConfig.API.bsProBiddingApi.update
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片分页
    page(data, callback) {
      let url = apiConfig.API.bsProBiddingApi.page
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片详情
    getById(data, callback) {
      let url = apiConfig.API.bsProBiddingApi.getById
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    },
    //卡片删除
    delete(data, callback) {
      let url = apiConfig.API.bsProBiddingApi.delete
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    }
  }
  //招标信息导入
  static sysImportApi = {
    importFileApi(data, callback) {
      let url = apiConfig.API.sysImportFileApi.sysImportApi
      axiosUtil.postAddJson(url, { ...data }, function (res) {
        callback(res)
      })
    }
  }
}
